<template>
	<div class="publicformview">
		<!-- <el-button v-if='blockType==2' type="primary" size="mini" @click="handleUpdate()">录入</el-button> -->
		<div class="bottomTop" style="margin-top: 10px;">
			<el-table max-height='500px' v-loading="listLoading" :data="list" border fit highlight-current-row size="mini">
				<el-table-column align="center" label="年份" prop="year">
				</el-table-column>
			
				<el-table-column align="center" label="分值" prop="unitvalue">
				</el-table-column>
				
				<el-table-column align="center" label="单位租金" prop="unitrentprice">
				</el-table-column>
				
				<el-table-column align="center" label="租定金额" prop="rentprice">
				</el-table-column>
				
				<el-table-column align="center" label="生效时间" prop="taskTime">
				</el-table-column>
				
				<el-table-column align="center" label="操作人" prop="adminUser">
				</el-table-column>
				
				<el-table-column align="center" label="所属站" prop="aname">
				</el-table-column>
				
			</el-table>
		</div>
	<div class="publicpaginationview">
		<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
			:current-page="listQuery.pageNum" background :page-sizes="[10, 20, 50, 100]" :page-size="listQuery.pageSize"
			layout="total, sizes, prev, pager, next, jumper" :total="total" small></el-pagination>
	</div>
		
		<!-- <div class="saveContent">
			<el-button type="primary" @click="chaifenVisible = false" size="medium">保 存</el-button>
		</div> -->
		
		<el-dialog title="" :visible.sync="dialogVisible" width="50%" :before-close="handleClose">
			<el-form :model="addQuery" ref="dataForm" class="demo-ruleForm" label-position="right" label-width="150px">
				<el-form-item label="单位租金：" prop="unitrentprice">
					<el-input v-model="addQuery.unitrentprice"></el-input>
				</el-form-item>
				<el-form-item label="组定金额：" prop="rentprice">
					<el-input v-model="addQuery.rentprice"></el-input>
				</el-form-item>
				<el-form-item label="分值：" prop="unitvalue">
					<el-input v-model="addQuery.unitvalue"></el-input>
				</el-form-item>
				<el-form-item label="年份：" prop="year">
					<el-date-picker
					      v-model="addQuery.year"
					      type="year"
					      placeholder="选择年份">
					    </el-date-picker>
				</el-form-item>
			</el-form>
			<div class="saveContent">
				<el-button type="primary" @click="save" size="medium">保 存</el-button>
			</div>
		</el-dialog>
	</div>
</template>

<script>
	import dayjs from 'dayjs'
	import {
		roomYearRent,
		addRoomYearRent
	} from '@/api/industry'
	export default {
		props:{
			blockType:String,
			roomid:String
		},
		name: "fangwuxianzhuang",
		data() {
			return {
				listQuery: {
					pageNum: 1,
					pageSize: 20,
				},
				addQuery: {
					year: '',
					unitrentprice:'',
					rentprice:'',
					unitvalue:''
				},
				total: 0,
				options: [{
					key: "1"
				}],
				list: [ ],
				listLoading: false,
				dialogVisible: false,
				isChanquan: true,
				type: 1
			};
		},

		computed: {
		},

		mounted() {
			this.roomYearRent()
		},

		methods: {
			roomYearRent(){
				let data = {
					pageNum:this.listQuery.pageNum,
					pageSize:this.listQuery.pageSize,
					RoomID:this.roomid
				}
				if(this.roomid){
					roomYearRent(data).then(res=>{
						console.log(res)
						this.list = res.data.list
							this.total = res.data.total
					})
				}
				
			},
			save() {
				let data = {
					roomid:this.roomid,
					year:dayjs(this.addQuery.year).format('YYYY'),
					unitrentprice:this.addQuery.unitrentprice,
					rentprice:this.addQuery.rentprice,
					unitvalue:this.addQuery.unitvalue
				}
				addRoomYearRent(data).then(res => {
					console.log(res)
					this.dialogVisible = false;
					this.roomYearRent()
					this.$message({
						type: 'success',
						message: '操作成功!'
					});
				})
				this.reter()
			},
			reter(){
				this.addQuery.year='',
				this.addQuery.unitrentprice='',
				this.addQuery.rentprice='',
				this.addQuery.unitvalue=''
			},
			handleUpdate() {
				this.dialogVisible = true;
			},
			resetForm(val) {
				console.log("1");
				this.$refs[val].resetFields();
			},
			handleAddUser(type) {
				this.isChanquan = type == 1 ? true : false
			},
			handleSizeChange(val) {
				this.listQuery.pageNum = 1;
				this.listQuery.pageSize = val;
			},
			handleCurrentChange(val) {
				this.listQuery.pageNum = val;
			},
			returns() {
				this.$router.go(-1)
			},
			// 选择类型
			selectButton(type) {
				this.type = type
			},
			
			handleClose(done) {
				this.$confirm('确认关闭？')
					.then(_ => {
						done();
						this.reter()
					})
					.catch(_ => {});
			},
		},
	};
</script>

<style scoped>
	.headTop {
		width: 100%;
		display: flex;
		justify-content: space-between;

		.xinxi {
			display: flex;
			width: 800px;
		}
	}

	.el-form-item {
		justify-content: start !important;
	}

	.el-select {
		width: 180px;
	}

	.el-input {
		width: 460px;
	}

	.el-date-picker {
		width: 180px;
	}

	.bottomTop {
		width: 100%;
		display: flex;
		justify-content: end;
	}

	.tabButton {
		background: #EFF2F7;
		color: #333333;
		border: none;
	}

	.fangwuList {
		width:100%;
		background-color: #F5F5F5;
		margin: 3px auto 0;
		overflow: hidden;
	}

	.fangwuText {
		font-weight: bold;
		font-size: 16px;
		color: #008C93;
		margin-top: 20px;
		margin-left: 26px;
	}
	.saveContent {
		width: 100%;
		display: flex;
		justify-content: end;
		margin-top: 20px;
		padding-bottom: 20px;
	}
</style>